package com.niit.controller;


import com.niit.pojo.User;
import com.niit.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;


@Controller
public class UserController {

    @Autowired
    private UserService userService;
    //登录
    @RequestMapping("/login")
    public String index(){

        return "login";
    }

    @RequestMapping("/selectUser")
    public String selectUser( User user){

        User user1=userService.selectUser(user);
        System.out.println(user);
        if (user1!=null)
            return "index";
        else
            return "login";
    }

    @RequestMapping("/index")
    public String userIndex(){
        return "index_v3.html";

    }

    //注册
    @RequestMapping("/register")
    public String register(){
        return "register";
    }

    @RequestMapping("/addUser")
    public String addUser(User user){
        int num= userService.addUser(user);
        if (num>0)
            return "login";
        else
            return "register";
    }




}
